#coding=utf-8
import pygame

UP = 'up'
DOWN = 'down'
LEFT = 'left'
RIGHT = 'right'
LEFT_UP = 'left_up'
LEFT_DOWN = 'left_down'
RIGHT_UP = 'right_up'
RIGHT_DOWN = 'right_down'
GJ = 'gj'  # 攻击
LEFT_GJ = 'left_gj'
RIGHT_GJ = 'right_gj'
JN = 'jn'  # 技能
LEFT_JN = 'left_jn'
RIGHT_JN = 'right_jn'

# 必须要初始化，并且开启一个窗口，才能.convert_alpha()加载精灵
pygame.init()
ss = pygame.display.set_mode((1, 1), 0, 32)

# 明特萝莉资源主目录绝对路径
MT_resource_main_dir_path = 'image/role/MT_housemaid/'
# 明特萝莉行动指令列表
MT_action_cmd_list = [UP, DOWN, LEFT, RIGHT, LEFT_UP, LEFT_DOWN, RIGHT_UP, RIGHT_DOWN, GJ]
# 明特萝莉动作资源列表
MT_action_img_resource_dict = {}.fromkeys(MT_action_cmd_list)
for action in MT_action_img_resource_dict:
    MT_action_img_resource_dict[action] = []
# 加载精灵到明特萝莉动作资源列表
for action in MT_action_cmd_list:
    for number in range(20):
        # 不管这个动作有几个精灵，都循环很多次，报错时捕获并终止此循环,就能适应不同精灵数量的的动作
        img_path = MT_resource_main_dir_path + action + '_' + str(number + 1) + '.png'  # 生成图片路径
        try:
            sprite_surface = pygame.image.load(img_path).convert_alpha()  # 加载，转化精灵
        except pygame.error:
            break
        MT_action_img_resource_dict[action].append(sprite_surface)  # 添加到资源列表action_img_resource_dict


# 老虎资源主目录绝对路径
Tiger_resource_main_dir_path = 'image/role/Tiger/' # 老虎资源主目录路径
# 老虎行动指令列表
Tiger_action_cmd_list = [UP, DOWN, LEFT, RIGHT, LEFT_UP, LEFT_DOWN, RIGHT_UP, RIGHT_DOWN, LEFT_GJ, RIGHT_GJ,LEFT_JN, RIGHT_JN]
# 老虎动作资源列表
Tiger_action_img_resource_dict = {}.fromkeys(Tiger_action_cmd_list)
for action in Tiger_action_img_resource_dict:
    Tiger_action_img_resource_dict[action] = []
# 加载精灵到老虎动作资源列表
for action in Tiger_action_cmd_list:
    for number in range(20):
        # 不管这个动作有几个精灵，都循环很多次，报错时捕获并终止此循环,就能适应不同精灵数量的的动作
        img_path = Tiger_resource_main_dir_path + action + '_' + str(number + 1) + '.png'  # 生成图片路径
        try:
            sprite_surface = pygame.image.load(img_path).convert_alpha()  # 加载，转化精灵
        except pygame.error:
            break
        Tiger_action_img_resource_dict[action].append(sprite_surface)  # 添加到资源列表action_img_resource_dict